home *** CD-ROM | disk | FTP | other *** search
/ Ghost Rider iactivecard / Ghost Rider iactivecard.iso / pc / resurrection.swf / scripts / __Packages / someFrogs / Puzzles / SlidingGroup.as next >
Encoding:
Text File  |  2007-04-06  |  3.7 KB  |  133 lines

  1. class someFrogs.Puzzles.SlidingGroup extends someFrogs.Lake.MaskedPiece
  2. {
  3.    var xd;
  4.    var groupProps;
  5.    var yd;
  6.    var ini_depth;
  7.    var lb;
  8.    var piecesArr;
  9.    var onPress;
  10.    var onRelease;
  11.    var onReleaseOutside;
  12.    var onEnterFrame;
  13.    static var symbolName = "SlidingGroup";
  14.    static var symbolOwner = someFrogs.Puzzles.SlidingGroup;
  15.    var className = "SlidingGroup";
  16.    var enabled = false;
  17.    var active = true;
  18.    var xp = 0;
  19.    var yp = 0;
  20.    function SlidingGroup()
  21.    {
  22.       super();
  23.       this._x = this.xd = this.xp = this.groupProps.x;
  24.       this._y = this.yd = this.yp = this.groupProps.y;
  25.       this.ini_depth = this.getDepth();
  26.       this.set_hint_style();
  27.       this.setEnabled(this._parent.enabled);
  28.    }
  29.    function set_hint_style(Void)
  30.    {
  31.       if(this.lb != undefined)
  32.       {
  33.          this.lb.removeTextField();
  34.       }
  35.       if(this._parent._hintStyle != "none")
  36.       {
  37.          var _loc2_ = "";
  38.          if(this._parent._hintStyle == "count")
  39.          {
  40.             _loc2_ = this.groupProps.Hcount + 1;
  41.          }
  42.          else if(this._parent._hintStyle == "matrix")
  43.          {
  44.             _loc2_ = this.groupProps.Jorj + 1 + " " + (this.groupProps.Iorj + 1);
  45.          }
  46.          this.createLabel("lb",1001,_loc2_);
  47.          this.lb.styleName = this;
  48.          var _loc4_ = this.lb._getTextFormat();
  49.          var _loc3_ = _loc4_.getTextExtent(_loc2_);
  50.          this.lb._x = this.piecesArr[0].x;
  51.          this.lb._y = this.piecesArr[0].y;
  52.          this.lb._width = _loc3_.width + 5;
  53.          this.lb._height = _loc3_.height + 5;
  54.          this.lb.text = _loc2_;
  55.       }
  56.    }
  57.    function setEnabled(eFl)
  58.    {
  59.       this.enabled = eFl;
  60.       var _loc2_ = new Color(this);
  61.       if(eFl)
  62.       {
  63.          _loc2_.setTransform({ra:100,ga:100,ba:100});
  64.          if(this.active)
  65.          {
  66.             this.onPress = this.IamPressed;
  67.             this.onRelease = this.onReleaseOutside = this.IamReleased;
  68.          }
  69.          else
  70.          {
  71.             delete this.onPress;
  72.             delete this.onRelease;
  73.             delete this.onReleaseOutside;
  74.          }
  75.       }
  76.       else
  77.       {
  78.          this.onPress = this.onRelease = this.onReleaseOutside = null;
  79.          _loc2_.setTransform(this._parent.disabled_color);
  80.          this._x = this.xd = this.xp = this.groupProps.x;
  81.          this._y = this.yd = this.yp = this.groupProps.y;
  82.       }
  83.    }
  84.    function IamPressed()
  85.    {
  86.       this._parent.childPressed(this);
  87.    }
  88.    function IamReleased()
  89.    {
  90.       this._parent.childReleased(this);
  91.    }
  92.    function put_me_to(eJ, eI)
  93.    {
  94.       var _loc3_ = this.groupProps.x + (eI - this.groupProps.I) * this.groupProps.w;
  95.       var _loc2_ = this.groupProps.y + (eJ - this.groupProps.J) * this.groupProps.h;
  96.       this.xd = _loc3_;
  97.       this.yd = _loc2_;
  98.       this.renderMe();
  99.       this.groupProps.x = _loc3_;
  100.       this.groupProps.y = _loc2_;
  101.       this.groupProps.I = eI;
  102.       this.groupProps.J = eJ;
  103.    }
  104.    function renderMe()
  105.    {
  106.       this.xp = this.xp * 0.25 + (this.xd - this._x) * 0.4;
  107.       this.yp = this.yp * 0.25 + (this.yd - this._y) * 0.4;
  108.       if(Math.abs(this.xp) < 0.25 && Math.abs(this.yp) < 0.25 && Math.abs(this._x - this.xd) < 0.25 && Math.abs(this._y - this.yd) < 0.25)
  109.       {
  110.          this._x = this.xd;
  111.          this._y = this.yd;
  112.          delete this.onEnterFrame;
  113.       }
  114.       else
  115.       {
  116.          this._x += this.xp;
  117.          this._y += this.yp;
  118.          if(this.onEnterFrame != this.renderMe)
  119.          {
  120.             this.onEnterFrame = this.renderMe;
  121.          }
  122.       }
  123.    }
  124.    function size(Void)
  125.    {
  126.       super.size();
  127.    }
  128.    function init(Void)
  129.    {
  130.       super.init();
  131.    }
  132. }
  133.